package com.io;

import java.io.*;

/**
 * 使用字符流复制文件，每次读取一个字符数据。
 *
 * @author: Jovi
 * @createTime: 2017-06-20 16:39
 **/
public class TestIOCopy2 {
    public static void main(String[] args) {
        Reader reader = null;
        Writer writer = null;
        try {
            reader = new FileReader("poem.txt");
            writer = new FileWriter("poem2.txt");
            int n ;
            while ((n = reader.read()) != -1) {
                writer.write(n);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
